/* Octopus PDF - A simple document viewer for Android.
   Copyright (C) 2013  Gerald Thaler

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
package de.geraldthaler.octopuspdf.util;

import static java.lang.Math.min;

/**
 * @author Gerald Thaler
 */
public final class Arrays {
    public static int[] copyOf(final int[] original, final int newLength) {
        final int[] copy = new int[newLength];
        System.arraycopy(original, 0, copy, 0, min(newLength, original.length));
        return copy;
    }

    private Arrays() {
        // no instances
    }
}
